
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>mysql性能监控Lepus · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    golang
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../golang/资料收集.html">
            
                <a href="../golang/资料收集.html">
            
                    
                    资料收集
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    mysql
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="mysql性能监控Lepus.html">
            
                <a href="mysql性能监控Lepus.html">
            
                    
                    mysql性能监控Lepus
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    nginx
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../nginx/nginxWebUi.html">
            
                <a href="../nginx/nginxWebUi.html">
            
                    
                    nginxWebUi
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >mysql性能监控Lepus</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="mysql&#x6027;&#x80FD;&#x76D1;&#x63A7;lepus">mysql&#x6027;&#x80FD;&#x76D1;&#x63A7;Lepus</h2>
<p>&#x7BA1;&#x7406;&#x754C;&#x9762;&#x5730;&#x5740;</p>
<pre><code>http://47.114.163.161/index.php/login?return_url=http://47.114.163.161/index.php
admin
Lepusadmin
</code></pre><p>&#x5B98;&#x7F51;</p>
<pre><code>https://www.lepus.cc/product/
</code></pre><h3 id="&#x76D1;&#x63A7;&#x7A0B;&#x5E8F;&#x5B89;&#x88C5;&#x5728;&#x72EC;&#x7ACB;&#x7684;&#x670D;&#x52A1;&#x5668;&#x4E0A;">&#x76D1;&#x63A7;&#x7A0B;&#x5E8F;&#x5B89;&#x88C5;&#x5728;&#x72EC;&#x7ACB;&#x7684;&#x670D;&#x52A1;&#x5668;&#x4E0A;</h3>
<p>&#x5B89;&#x88C5;&#x4F9D;&#x8D56;</p>
<pre><code>yum -y install python-devel
</code></pre><p>&#x5B89;&#x88C5;mariadb&#x6570;&#x636E;&#x5E93;</p>
<pre><code>&#x5378;&#x8F7D;
[root@lepus ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@lepus ~]# rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
&#x5B89;&#x88C5;
[root@localhost ~]# yum -y install mariadb-server
[root@lepus ~]# systemctl start mariadb
[root@lepus ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we&apos;ll need the current
password for the root user.  If you&apos;ve just installed MariaDB, and
you haven&apos;t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from &apos;localhost&apos;.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named &apos;test&apos; that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you&apos;ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
</code></pre><p>&#x90E8;&#x7F72;python&#x76F8;&#x5173;</p>
<pre><code>[root@lepus ~]# which mysql_config
/usr/bin/which: no mysql_config in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@lepus ~]# yum -y install mysql-devel
[root@lepus ~]# which mysql_config
/usr/bin/mysql_config
</code></pre><p>&#x5B89;&#x88C5;mysql&#x9A71;&#x52A8;&#x5305;</p>
<pre><code>wget https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
[root@ark software]# cd MySQL-python-1.2.5
[root@ark MySQL-python-1.2.5]# which mysql_config
/usr/bin/mysql_config

[root@ark MySQL-python-1.2.5]# vi site.cfg
[options]
# embedded: link against the embedded server library
# threadsafe: use the threadsafe client
# static: link against a static library (probably required for embedded)

embedded = False
threadsafe = True
static = False

# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.
mysql_config = /usr/bin/mysql_config

# http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip
# Windows connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build.
#connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2

[root@ark MySQL-python-1.2.5]# pip install setuptools
[root@ark MySQL-python-1.2.5]# python setup.py build
[root@ark MySQL-python-1.2.5]# python setup.py install
</code></pre><p>&#x5B89;&#x88C5;Lepus</p>
<pre><code>[root@ark ~]# cd /usr/local/
[root@ark local]# wget https://github.com/ruyi1024/lepus/archive/refs/heads/master.zip
[root@ark local]# cd lepus-master/
[root@ark lepus-master]# chmod +x lepus*
[root@ark lepus-master]# ln -s /usr/local/lepus/lepus /usr/local/sbin/lepus
[root@ark lepus-master]# ln -s /usr/local/lepus/lepus_monitor /usr/local/sbin/lepus_monitor

[root@lepus lepus]# python test_driver_mysql.py
MySQL python drivier is ok!
</code></pre><p>&#x521B;&#x5EFA;Lepus&#x6570;&#x63A7;&#x5E76;&#x6388;&#x6743;</p>
<pre><code>MariaDB [(none)]&gt; create database lepus default character set utf8;
MariaDB [(none)]&gt; grant select,insert,update,delete,create on lepus.* to &apos;lepus_user&apos;@&apos;localhost&apos; identified by &apos;Hadoop123456&apos;;
MariaDB [(none)]&gt; flush privileges;
</code></pre><p>&#x5BFC;&#x5165;Lepus&#x6570;&#x636E;</p>
<pre><code>[root@ark lepus-master]# mysql -ulepus_user -p lepus &lt; sql/lepus_table.sql
[root@ark lepus-master]# mysql -ulepus_user -p lepus &lt; sql/lepus_data.sql
</code></pre><p>&#x4FEE;&#x6539;Lepus&#x914D;&#x7F6E;&#x6587;&#x4EF6;</p>
<pre><code>[root@ark lepus-master]# vi etc/config.ini
###&#x76D1;&#x63A7;&#x673A;MySQL&#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x5730;&#x5740;###
[monitor_server]
host=&quot;127.0.0.1&quot;
port=3306
user=&quot;lepus_user&quot;
passwd=&quot;xxxx&quot;
dbname=&quot;lepus&quot;
</code></pre><p>&#x542F;&#x52A8;Lepus</p>
<pre><code>[root@ark lepus]# ./lepus start
lepus server start success!
</code></pre><p>&#x542F;&#x52A8;web&#x754C;&#x9762;(&#x754C;&#x9762;&#x662F;php&#x7A0B;&#x5E8F;)</p>
<pre><code>[root@ark lepus]# vi web/application/config/database.php
$db[&apos;default&apos;][&apos;hostname&apos;] = &apos;127.0.0.1&apos;;
$db[&apos;default&apos;][&apos;port&apos;]     = &apos;3306&apos;;
$db[&apos;default&apos;][&apos;username&apos;] = &apos;lepus_user&apos;;
$db[&apos;default&apos;][&apos;password&apos;] = &apos;Hadoop123456&apos;;
$db[&apos;default&apos;][&apos;database&apos;] = &apos;lepus&apos;;
$db[&apos;default&apos;][&apos;dbdriver&apos;] = &apos;mysql&apos;;
</code></pre><p>&#x90E8;&#x7F72;&#x6162;&#x67E5;&#x8BE2;&#x540C;&#x6B65;&#x811A;&#x672C;</p>
<pre><code>yum -y install perl-IO-Socket-SSL
yum -y install perl-DBI
yum -y install perl-DBD-MySQL
yum install perl-Digest-MD5
wget https://downloads.percona.com/downloads/percona-toolkit/3.3.1/binary/redhat/7/x86_64/percona-toolkit-3.3.1-1.el7.x86_64.rpm
rpm -ivh percona-toolkit-3.3.1-1.el7.x86_64.rpm 

[root@lepus lepus]# scp client/mysql/lepus_slowquery.sh root@xx.xx.xx.xx:/usr/local/sbin/
</code></pre><p>&#x754C;&#x9762;&#x6548;&#x679C;</p>
<p><img src="images/lepus0001.jpg" alt=""></p>
<p><img src="images/lepus0002.jpg" alt=""></p>
<p><img src="images/lepus0003.jpg" alt=""></p>
<p><img src="images/lepus0004.png" alt=""></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"mysql性能监控Lepus","level":"1.3.1","depth":2,"next":{"title":"nginx","level":"1.4","depth":1,"ref":"","articles":[{"title":"nginxWebUi","level":"1.4.1","depth":2,"path":"nginx/nginxWebUi.md","ref":"nginx/nginxWebUi.md","articles":[]}]},"previous":{"title":"mysql","level":"1.3","depth":1,"ref":"","articles":[{"title":"mysql性能监控Lepus","level":"1.3.1","depth":2,"path":"mysql/mysql性能监控Lepus.md","ref":"mysql/mysql性能监控Lepus.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"mysql/mysql性能监控Lepus.md","mtime":"2021-08-11T06:13:02.092Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-08-11T07:31:23.581Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

